<?php include_once './header.php'; ?>

<? 
include('config.php'); 
echo "<table border=1 >"; 
echo "<tr>"; 
echo "<td><b>Curso</b></td>"; 
echo "<td><b>Sem 1</b></td>"; 
echo "<td><b>Sem 2</b></td>"; 
echo "<td><b>Sem 3</b></td>"; 
echo "<td><b>Sem 4</b></td>"; 
echo "<td><b>Sem 5</b></td>"; 
echo "<td><b>Sem 6</b></td>"; 
echo "<td><b>Sem 7</b></td>"; 
echo "<td><b>Sem 8</b></td>"; 
echo "<td><b>Sem 9</b></td>"; 
echo "<td><b>Sem 10</b></td>"; 
echo "<td><b>Sem 11</b></td>"; 
echo "<td><b>Sem 12</b></td>"; 
echo "<td><b>Sem 13</b></td>"; 
echo "<td><b>Sem 14</b></td>"; 
echo "<td><b>Sem 15</b></td>"; 
echo "<td><b>Sem 16</b></td>"; 
echo "<td><b>Sem 17</b></td>"; 
echo "<td><b>Sem 18</b></td>"; 
echo "<td><b>Sem 19</b></td>"; 
echo "<td><b>Sem 20</b></td>"; 
echo "<td><b>Sem 21</b></td>"; 
echo "<td><b>Sem 22</b></td>"; 
echo "<td><b>Sem 23</b></td>"; 
echo "<td><b>Sem 24</b></td>"; 
echo "</tr>"; 
$result = mysql_query("SELECT curs.idCurso, curs.nombreCurso, 
MAX(if(1=prec.idsemanasp,prec.precioCurso, null))'semana1',
MAX(if(2=prec.idsemanasp,prec.precioCurso, null))'semana2',
MAX(if(3=prec.idsemanasp,prec.precioCurso, null))'semana3',
MAX(if(4=prec.idsemanasp,prec.precioCurso, null))'semana4',
MAX(if(5=prec.idsemanasp,prec.precioCurso, null))'semana5',
MAX(if(6=prec.idsemanasp,prec.precioCurso, null))'semana6',
MAX(if(7=prec.idsemanasp,prec.precioCurso, null))'semana7',
MAX(if(8=prec.idsemanasp,prec.precioCurso, null))'semana8',
MAX(if(9=prec.idsemanasp,prec.precioCurso, null))'semana9',
MAX(if(10=prec.idsemanasp,prec.precioCurso, null))'semana10',
MAX(if(11=prec.idsemanasp,prec.precioCurso, null))'semana11',
MAX(if(12=prec.idsemanasp,prec.precioCurso, null))'semana12',
MAX(if(13=prec.idsemanasp,prec.precioCurso, null))'semana13',
MAX(if(14=prec.idsemanasp,prec.precioCurso, null))'semana14',
MAX(if(15=prec.idsemanasp,prec.precioCurso, null))'semana15',
MAX(if(16=prec.idsemanasp,prec.precioCurso, null))'semana16',
MAX(if(17=prec.idsemanasp,prec.precioCurso, null))'semana17',
MAX(if(18=prec.idsemanasp,prec.precioCurso, null))'semana18',
MAX(if(19=prec.idsemanasp,prec.precioCurso, null))'semana19',
MAX(if(20=prec.idsemanasp,prec.precioCurso, null))'semana20',
MAX(if(21=prec.idsemanasp,prec.precioCurso, null))'semana21',
MAX(if(22=prec.idsemanasp,prec.precioCurso, null))'semana22',
MAX(if(23=prec.idsemanasp,prec.precioCurso, null))'semana23',
MAX(if(24=prec.idsemanasp,prec.precioCurso, null))'semana24'
FROM cursos curs, precios prec
Where prec.idcursop=curs.idcurso 
group by curs.idCurso
order by 1") or trigger_error(mysql_error()); 
while($row = mysql_fetch_array($result)){ 
foreach($row AS $key => $value) { $row[$key] = stripslashes($value); } 
echo "<tr>";  
echo "<td valign='top'>" . nl2br( $row['nombreCurso']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['semana1']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['semana2']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['semana3']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['semana4']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['semana5']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['semana6']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['semana7']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['semana8']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['semana9']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['semana10']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['semana11']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['semana12']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['semana13']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['semana14']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['semana15']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['semana16']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['semana17']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['semana18']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['semana19']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['semana20']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['semana21']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['semana22']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['semana23']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['semana24']) . "</td>";  
echo "<td valign='top'><a href=editCursosNL.php?idCurso={$row['idCurso']}>Edit</a></td>"; 
echo "</tr>"; 
} 
echo "</table>"; 
echo "<a href=newService.php>New Row</a>"; 
?>

<?php include_once './footer.php'; ?>
<!--
SELECT curs.idCurso, curs.nombreCurso, 
MAX(if(1=prec.idsemanasp,prec.precioCurso, null))"semana 1",
MAX(if(2=prec.idsemanasp,prec.precioCurso, null))"semana 2",
MAX(if(3=prec.idsemanasp,prec.precioCurso, null))"semana 3",
MAX(if(4=prec.idsemanasp,prec.precioCurso, null))"semana 4",
MAX(if(5=prec.idsemanasp,prec.precioCurso, null))"semana 5",
MAX(if(6=prec.idsemanasp,prec.precioCurso, null))"semana 6",
MAX(if(7=prec.idsemanasp,prec.precioCurso, null))"semana 7",
MAX(if(8=prec.idsemanasp,prec.precioCurso, null))"semana 8",
MAX(if(9=prec.idsemanasp,prec.precioCurso, null))"semana 9",
MAX(if(10=prec.idsemanasp,prec.precioCurso, null))"semana 10",
MAX(if(11=prec.idsemanasp,prec.precioCurso, null))"semana 11",
MAX(if(12=prec.idsemanasp,prec.precioCurso, null))"semana 12",
MAX(if(13=prec.idsemanasp,prec.precioCurso, null))"semana 13",
MAX(if(14=prec.idsemanasp,prec.precioCurso, null))"semana 14",
MAX(if(15=prec.idsemanasp,prec.precioCurso, null))"semana 15",
MAX(if(16=prec.idsemanasp,prec.precioCurso, null))"semana 16",
MAX(if(17=prec.idsemanasp,prec.precioCurso, null))"semana 17",
MAX(if(18=prec.idsemanasp,prec.precioCurso, null))"semana 18",
MAX(if(19=prec.idsemanasp,prec.precioCurso, null))"semana 19",
MAX(if(20=prec.idsemanasp,prec.precioCurso, null))"semana 20",
MAX(if(21=prec.idsemanasp,prec.precioCurso, null))"semana 21",
MAX(if(22=prec.idsemanasp,prec.precioCurso, null))"semana 22",
MAX(if(23=prec.idsemanasp,prec.precioCurso, null))"semana 23",
MAX(if(24=prec.idsemanasp,prec.precioCurso, null))"semana 24",
FROM cursos curs, precios prec
Where prec.idcursop=curs.idcurso 
group by curs.idCurso
order by 1  -->